package com.sky.service.impl;

import com.sky.result.Result;
import com.sky.service.ShopService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;

import org.springframework.stereotype.Service;

@Service
public class ShopServiceImpl implements ShopService {
    @Autowired
    private StringRedisTemplate redisTemplate;

    public static final String KEY = "SHOP_STATUS";

    /**
     * 获取营业状态
     *
     * @return
     */
    @Override
    public Result status() {
        String status = redisTemplate.opsForValue().get(KEY);
        return  Result.success(Integer.parseInt(status)) ;
    }

    /**
     * 设置营业状态
     *
     * @param status
     * @return
     */
    @Override
    public Result upadteStatus(Integer status) {
        redisTemplate.opsForValue().set(KEY,status+"");
        return Result.success();
    }
}
